<template>
  <view class="rain-container" style="background-color: #aaff00;">
    <!-- 雨滴元素 -->
    <view 
      v-for="(drop, index) in drops" 
      :key="index" 
      class="raindrop"
      :style="{
        left: drop.left + 'rpx',
        animationDuration: drop.duration + 's',
        animationDelay: drop.delay + 's',
        height: drop.length + 'rpx',
        width: drop.width + 'rpx'
      }"
    ></view>
    
    <!-- 雨面效果 -->
    <view class="rain-surface"></view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      drops: []
    }
  },
  mounted() {
    this.createRainDrops(100); // 创建100滴雨
  },
  methods: {
    createRainDrops(count) {
      for (let i = 0; i < count; i++) {
        this.drops.push({
          left: Math.random() * 750, // 750rpx是标准宽度
          duration: 0.5 + Math.random() * 1, // 下落时间0.5-1.5秒
          delay: Math.random() * 2, // 延迟0-2秒
          length: 40 + Math.random() * 60, // 雨滴长度40-100rpx
          width: 1 + Math.random() * 2 // 雨滴宽度1-3rpx
        });
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.rain-container {
/*  position: fixed;
  top: 0;
  left: 0; */
  width: 750rpx;
  height: 100%;
/*  pointer-events: none;
  z-index: 1000;
  overflow: hidden; */
  background-color: #00ff00;
}

.raindrop {
  position: absolute;
  background: linear-gradient(to bottom, rgba(200, 230, 255, 0.8), rgba(200, 230, 255, 0.3));
  border-radius: 60rpx;
  animation: falling linear infinite;
  transform: translateY(-100%);
}

@keyframes falling {
  to {
    transform: translateY(calc(100vh + 100rpx));
  }
}

.rain-surface {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 20rpx;
  background: rgba(200, 230, 255, 0.2);
  box-shadow: 0 0 30rpx 30rpx rgba(200, 230, 255, 0.2);
  animation: ripple 0.5s infinite alternate;
}

@keyframes ripple {
  from {
    opacity: 0.2;
    height: 20rpx;
  }
  to {
    opacity: 0.4;
    height: 40rpx;
  }
}
</style>